home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 76 / DVD Actual 1 Marzo 2003.iso / Trial / TurboCAD 7.1 Pro / Data.Cab / F24740_AutoJPEG.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-10  |  18.0 KB  |  592 lines

  1. /******************************************************************/
  2. /*                                                                */
  3. /*                      TurboCAD for Windows                      */
  4. /*                   Copyright (c) 1993 - 1999                    */
  5. /*             International Microcomputer Software, Inc.         */
  6. /*                            (IMSI)                              */
  7. /*                      All rights reserved.                      */
  8. /*                                                                */
  9. /******************************************************************/
  10. // AutoJPEG.cpp : implementation file
  11. //
  12.  
  13. #include "stdafx.h"
  14. #include "JPEG.h"
  15. #include "AutoJPEG.h" // This class
  16.  
  17. // How to create a JPEG?
  18. #ifdef USE_LEADTOOOLS
  19. // Source code license required
  20. #else
  21. // Exported function from JPEGLIB.DLL 
  22. __declspec(dllimport) extern "C" int DIBToJPEG(HGLOBAL hDib, LPCSTR outfilename);
  23. #endif
  24.  
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30.  
  31. // Standard variants
  32. COleVariant t(-1L, VT_BOOL);
  33. COleVariant f(0L, VT_BOOL);
  34. COleVariant missing((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
  35.  
  36. // IID's From Imsigx.i_c.
  37. const IID IID_Graphics = 
  38.     {0x6A48110A,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}};
  39. const IID IID_Filter = 
  40.     {0x6A48111B,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}};
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CAutoJPEG
  44.  
  45. // We get all these functions from the Visual C++ ClassWizard...
  46.  
  47. IMPLEMENT_DYNCREATE(CAutoJPEG, CCmdTarget)
  48.  
  49. CAutoJPEG::CAutoJPEG()
  50. {
  51.     EnableAutomation();
  52.     
  53.     // To keep the application running as long as an OLE automation 
  54.     //    object is active, the constructor calls AfxOleLockApp.
  55.     
  56.     AfxOleLockApp();
  57. }
  58.  
  59. CAutoJPEG::~CAutoJPEG()
  60. {
  61.     // To terminate the application when all objects created with
  62.     //     with OLE automation, the destructor calls AfxOleUnlockApp.
  63.     
  64.     AfxOleUnlockApp();
  65. }
  66.  
  67.  
  68. void CAutoJPEG::OnFinalRelease()
  69. {
  70.     // When the last reference for an automation object is released
  71.     // OnFinalRelease is called.  The base class will automatically
  72.     // deletes the object.  Add additional cleanup required for your
  73.     // object before calling the base class.
  74.  
  75.     CCmdTarget::OnFinalRelease();
  76. }
  77.  
  78.  
  79. BEGIN_MESSAGE_MAP(CAutoJPEG, CCmdTarget)
  80.     //{{AFX_MSG_MAP(CAutoJPEG)
  81.         // NOTE - the ClassWizard will add and remove mapping macros here.
  82.     //}}AFX_MSG_MAP
  83. END_MESSAGE_MAP()
  84.  
  85. BEGIN_DISPATCH_MAP(CAutoJPEG, CCmdTarget)
  86.     //{{AFX_DISPATCH_MAP(CAutoJPEG)
  87.     DISP_PROPERTY_EX(CAutoJPEG, "ClassID", GetClassID, SetNotSupported, VT_BSTR)
  88.     DISP_PROPERTY_EX(CAutoJPEG, "Description", GetDescription, SetNotSupported, VT_BSTR)
  89.     DISP_PROPERTY_EX(CAutoJPEG, "Info", GetInfo, SetNotSupported, VT_BSTR)
  90.     DISP_PROPERTY_EX(CAutoJPEG, "LastError", GetLastError, SetNotSupported, VT_BSTR)
  91.     DISP_FUNCTION(CAutoJPEG, "CheckFlat", CheckFlat, VT_I4, VTS_DISPATCH VTS_BSTR VTS_I4 VTS_PVARIANT)
  92.     DISP_FUNCTION(CAutoJPEG, "PreviewFlat", PreviewFlat, VT_I4, VTS_DISPATCH VTS_BSTR VTS_I4 VTS_I4 VTS_PBSTR VTS_PVARIANT)
  93.     DISP_FUNCTION(CAutoJPEG, "ReadFlat", ReadFlat, VT_I4, VTS_BSTR VTS_I4 VTS_DISPATCH VTS_PVARIANT)
  94.     DISP_FUNCTION(CAutoJPEG, "WriteFlat", WriteFlat, VT_I4, VTS_BSTR VTS_I4 VTS_DISPATCH VTS_PVARIANT)
  95.     DISP_FUNCTION(CAutoJPEG, "ReadSetup", ReadSetup, VT_BOOL, VTS_DISPATCH)
  96.     DISP_FUNCTION(CAutoJPEG, "WriteSetup", WriteSetup, VT_BOOL, VTS_DISPATCH)
  97.     DISP_FUNCTION(CAutoJPEG, "Initialize", Initialize, VT_BOOL, VTS_DISPATCH)
  98.     //}}AFX_DISPATCH_MAP
  99. END_DISPATCH_MAP()
  100.  
  101. // Note: we add support for IID_ITurboCADFilter to support typesafe binding
  102. //  from VBA.  This IID must match the GUID that is attached to the 
  103. //  dispinterface in the .ODL file.  Do not change this GUID if make your own custom filter!
  104.  
  105. // {6A481302-E531-11CF-A115-00A024158DAF}
  106. static const IID IID_ITurboCADFilter =
  107. {0x6A481302,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}};
  108.  
  109. BEGIN_INTERFACE_MAP(CAutoJPEG, CCmdTarget)
  110.     INTERFACE_PART(CAutoJPEG, IID_ITurboCADFilter, Dispatch)
  111. END_INTERFACE_MAP()
  112.  
  113. // Note: if you make a custom filter by copying this file, make sure to replace the following
  114. //  GUID with a new GUID that matches the uuid statement in the coclass declaration in the 
  115. //  .ODL file.  This is the GUID that OLE will use to register and create the automation object.
  116.  
  117. // {28696026-B7E6-11D0-9B3B-444553540000}
  118. IMPLEMENT_OLECREATE(CAutoJPEG, "JPEG.AutoJPEG", 0x28696026, 0xb7e6, 0x11d0, 0x9b, 0x3b, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0)
  119.  
  120. /////////////////////////////////////////////////////////////////////////////
  121. // CAutoJPEG message handlers
  122.  
  123. // GetClassID:  return the filter's class id, as a string.
  124.  
  125. BSTR CAutoJPEG::GetClassID() 
  126. {
  127.     // Convert our GUID (see IMPLEMENT_OLECREATE macro) to a string
  128.     LPOLESTR olestr;
  129.     HRESULT hRes = ::StringFromCLSID(guid, &olestr);
  130.     if (FAILED(hRes))
  131.         return NULL;
  132.  
  133.     BSTR bstr = ::SysAllocString(olestr);
  134.     CoTaskMemFree(olestr);
  135.     return bstr;
  136. }
  137.  
  138. // GetDescription:  return the filter's description.
  139.  
  140. BSTR CAutoJPEG::GetDescription() 
  141. {
  142.     // Get the description from the resource
  143.     CString strResult;
  144.     strResult.LoadString(IDS_AUTOJPEG_DESC);
  145.  
  146.     return strResult.AllocSysString();
  147. }
  148.  
  149. // GetInfo:  return the filter's info string
  150. // Our info string is "JPEG.AutoJPEG,JPEG (JFIF) File,0,10,JPG,JPG", stored in the DLL's
  151. // resource.
  152.  
  153. // The info string contains the following fields, delimited by commas:
  154. // Field Name                                Value
  155. // 1.    Filter ID                           "JPEG.AutoJPEG"  
  156. //        Used as the internal name (must be unique).
  157. //        Should be the same as the ProgID registered for the server.
  158. //        TurboCAD reserves names beginning with an asterisk.
  159. // 2.    File type string for common dialog  "JPEG (JFIF) File";  
  160. //        This string appears in Windows dialog file type combo box.
  161. // 3.    Document type handled by filter     0
  162. //        This should always be zero for automation filters.
  163. // 4.    Priority                            10
  164. //        Arbitrary integer value used to determine search order for multiple filters which
  165. //        support the same document type and file extension.
  166. // 5.    Exported function name prefix       "JPG"
  167. //        Not used by automation filters, but a non-blank string must be supplied.
  168. // 6-n.  File extensions                     "JPG"
  169. //        Used in common dialog and for matching.
  170.  
  171. BSTR CAutoJPEG::GetInfo() 
  172. {
  173.     // Get the description from the resource
  174.     CString strResult;
  175.     strResult.LoadString(IDS_AUTOJPEG_INFO);
  176.  
  177.     return strResult.AllocSysString();
  178. }
  179.  
  180.  
  181. // GetLastError:  return descriptive information about the last error that occurred during an
  182. // open or save operation.  A smarter filter would save state somewhere and return better
  183. // diagnostics.
  184.  
  185. BSTR CAutoJPEG::GetLastError() 
  186. {
  187.     CString strResult;
  188.     strResult.LoadString(IDS_AUTOJPEG_ERROR_UNKNOWN);
  189.  
  190.     return strResult.AllocSysString();
  191. }
  192.  
  193. // CheckFlat:  file readers get called with this method to see if they can read the file.
  194. // If we were a file reader, we would look for a JPEG header.
  195.  
  196. long CAutoJPEG::CheckFlat(LPDISPATCH ThisFilter, LPCTSTR FileName, long ContextFlags, VARIANT FAR* QueryString) 
  197. {
  198.     // We are not implementing a reader
  199.     AfxThrowOleException(E_NOTIMPL);
  200.     return 0;
  201. }
  202.  
  203. // PreviewFlat:  file readers get called with this method to get a description string and a
  204. // (bitmap or metafile) thumbnail from the file.  If we were a file reader, we would create a
  205. // bitmap or StdPicture object from the JPEG file.
  206.  
  207. long CAutoJPEG::PreviewFlat(LPDISPATCH ThisFilter, LPCTSTR FileName, long ThumbWidth, long ThumbHeight, BSTR FAR* Description, VARIANT FAR* Thumbnail) 
  208. {
  209.     // We are not implementing a reader
  210.     AfxThrowOleException(E_NOTIMPL);
  211.     return 0;
  212. }
  213.  
  214. // ReadFlat:  file readers get called with this method to read graphics from the file and
  215. // add to the Graphics collection.  The Drawing object that we're reading into can be 
  216. // obtained by calling Graphics->get_Drawing.
  217.  
  218. long CAutoJPEG::ReadFlat(LPCTSTR FileName, long ContextFlags, LPDISPATCH Graphics, VARIANT FAR* QueryString) 
  219. {
  220.     // We are not implementing a reader
  221.     AfxThrowOleException(E_NOTIMPL);
  222.     return 0;
  223. }
  224.  
  225. // WriteFlat:  file writers get called with this method to write graphics to the file.
  226. // The Drawing object that we're writing from from is obtained by calling Graphics->get_Drawing.
  227.  
  228. long CAutoJPEG::WriteFlat(LPCTSTR FileName, long ContextFlags, LPDISPATCH Grfs, VARIANT FAR* QueryString) 
  229. {
  230.     Graphics* pGraphics = NULL;
  231.     if (FAILED(Grfs->QueryInterface(IID_Graphics, (void**)&pGraphics)))
  232.         return -101;
  233.  
  234. #ifdef USE_LEADTOOLS
  235.     // Source code license required!
  236.  
  237.     // If we were licensed, we could accomplish the task as follows:
  238.     //   1. Use LEADTOOLS to get a (bitmap) DC to draw onto.
  239.     //   2. Set up a View on our drawing with this DC.
  240.     //   3. Refresh the View (painting onto its DC).
  241.     //   4. Let LEADTOOLS or another utility to save the bitmap on the DC to a JPEG file.
  242.     //   5. Destroy the DC.
  243.  
  244. #else
  245.     // Since we're using our custom JPEG library (which expects a DIB in memory), we will:
  246.     //   1. Set up a View on our drawing (no DC necessary).
  247.     //   2. Open a bitmap DC on the View.
  248.     //   3. Refresh the View (painting onto its DC).
  249.     //   4. Close the bitamp DC and retrieve the DIB.
  250.     //   5. Pass the DIB to our special function DIBToJPEG.
  251.     //   6. Dispose of the memory in the DIB.
  252.  
  253.     // Copyright notice:  DIBToJPEG is an exported function, part of a DLL created using the 
  254.     //  Independent JPEG Group's JPEG encoding/decoding library, modified in part by IMSI.
  255.     //  Please read the file "README" that is in this directory for more information on
  256.     //  JPEG, the IJG and the JPEG library.
  257.  
  258.     long nError = -101;
  259.  
  260.     HGLOBAL hDib = NULL;
  261.     IDrawing* pIDrawing = NULL;
  262.     if (SUCCEEDED(pGraphics->get_Drawing(&pIDrawing)))
  263.     {
  264.         Views* pViews = NULL;
  265.         if (SUCCEEDED(pIDrawing->get_Views(&pViews)))
  266.         {
  267.             View* pView = NULL;
  268.             if (SUCCEEDED(pViews->Add(&missing, &missing, &pView)))
  269.             {
  270.                 // To set the image width and height, we use settings stored in
  271.                 // TurboCAD's INI file.  These settings are transfered to our 
  272.                 // WriteSetup dialog for use by us.  See comments on the WriteSetup
  273.                 // function below, and the code in WSetup.cpp for more information.
  274.                 IApplication* pIApp;
  275.                 if (SUCCEEDED(pGraphics->get_Application(&pIApp)))
  276.                 {
  277.                     CString strProfileName;
  278.                     if (GetProfileName(pIApp, strProfileName))
  279.                         m_dlg.FromProfile(strProfileName);
  280.                     pIApp->Release();
  281.                 }
  282.                 
  283.                 // Set up size for bitmap DC
  284.                 HRESULT hRes;
  285.                 hRes = pView->put_Update(FALSE);
  286.                 hRes = pView->put_MappingMode(MM_TEXT);
  287.                 hRes = pView->put_ScreenLeft(0.0);
  288.                 hRes = pView->put_ScreenTop(0.0);
  289.                 hRes = pView->put_ScreenWidth((double)m_dlg.m_nWidth);
  290.                 hRes = pView->put_ScreenHeight((double)m_dlg.m_nHeight);
  291.                 hRes = pView->ZoomToExtents(); 
  292.                 hRes = pView->put_Update(TRUE);
  293.  
  294.                 // Draw our extents on the View as a bitmap
  295.                 long lBitmapDC = 0;
  296.                 hRes = pView->OpenBitmapDC(&lBitmapDC);
  297.                 if (SUCCEEDED(hRes))
  298.                 {
  299.                     hRes = pView->Refresh();
  300.                     hRes = pView->CloseBitmapDC((long*)&hDib);
  301.                 }
  302.  
  303.                 // Done with view
  304.                 pView->Delete();
  305.                 pView->Release();
  306.             }
  307.             pViews->Release();
  308.         }
  309.         pIDrawing->Release();
  310.     }
  311.  
  312.     if (hDib != NULL)
  313.     {
  314.         // Use function in JPEGLIB.DLL to save as a JPEG(JFIF) file
  315.         // Should work with 8, 16, and 24-bit DIBs
  316.         nError = DIBToJPEG(hDib, FileName);
  317.         ::GlobalFree(hDib);
  318.     }
  319. #endif
  320.  
  321.     pGraphics->Release();
  322.     return nError;
  323. }
  324.  
  325. // ReadSetup:  called to allow user interface for file read settings.
  326.  
  327. BOOL CAutoJPEG::ReadSetup(LPDISPATCH ThisFilter) 
  328. {
  329.     // We are not implementing a reader.
  330.     AfxThrowOleException(E_NOTIMPL);
  331.  
  332.     return TRUE;
  333. }
  334.  
  335. // WriteSetup:  called to allow user interface for file write settings.
  336. // Our example allows users to specify the width and height of the JPEG image.
  337. // We could (with a little more work) control the bit depth, compression, etc.
  338.  
  339. BOOL CAutoJPEG::WriteSetup(LPDISPATCH ThisFilter) 
  340. {
  341.     // We store these settings in TurboCAD's INI file.
  342.     // First, get the file name.
  343.     CString strProfileName;
  344.     if (ThisFilter != NULL)
  345.     {
  346.         Filter* pFilter;
  347.         HRESULT hRes = ThisFilter->QueryInterface(IID_Filter, (void**)&pFilter);
  348.         if (SUCCEEDED(hRes))
  349.         {
  350.             IApplication* pIApp;
  351.             hRes = pFilter->get_Application(&pIApp);
  352.             if (SUCCEEDED(hRes))
  353.             {
  354.                 GetProfileName(pIApp, strProfileName);
  355.                 pIApp->Release();
  356.             }
  357.             pFilter->Release();
  358.         }
  359.     }
  360.  
  361.     // Initialize the setup dialog from the INI file, and run the dialog.
  362.     if (!strProfileName.IsEmpty())
  363.         m_dlg.FromProfile(strProfileName);
  364.     if (m_dlg.DoModal() == IDOK)
  365.     {
  366.         // Update the INI file if the user clicked OK
  367.         if (!strProfileName.IsEmpty())
  368.             m_dlg.ToProfile(strProfileName);
  369.     }
  370.     return TRUE;
  371. }
  372.  
  373. // Function called when Filter object has been added to application at startup.
  374. // We could install an event listener here, allocate memory, or whatever.
  375.  
  376. BOOL CAutoJPEG::Initialize(LPDISPATCH ThisFilter) 
  377. {
  378.     // We just return TRUE for success.  Returning FALSE would remove our Filter.
  379.     return TRUE;
  380. }
  381.  
  382. // Helper function for filter settings (accessed in WriteSetup).
  383. // We will store our settings in TurboCAD's INI file.
  384. // Another option is to store the settings in the Windows registry.
  385.  
  386. BOOL CAutoJPEG::GetProfileName(IApplication* pIApp, CString& strProfileName)
  387. {
  388.     BSTR bstrProfile;
  389.     HRESULT hRes = pIApp->get_ProfileName(0, &bstrProfile);
  390.     if (SUCCEEDED(hRes))
  391.     {
  392.         strProfileName = bstrProfile;
  393.         ::SysFreeString(bstrProfile);
  394.         return TRUE;
  395.     }
  396.     return FALSE;
  397. }
  398.  
  399. // DUAL_SUPPORT_START
  400. // The rest of this file is boilerplate dual interface stuff.  We use macros from MfcDual.h
  401. // and just wrap all of our implementation functions in TRY/CATCH blocks.
  402.  
  403. // delegate standard IDispatch methods to MFC IDispatch implementation
  404. DELEGATE_DUAL_INTERFACE(CAutoJPEG, DualJPEG)
  405.  
  406. // Our method and property functions can generally just
  407. // delegate back to the methods we generated using 
  408. // ClassWizard. However, if we set up properties to 
  409. // access variables directly, we will need to write the
  410. //  code to get/put the value into the variable.
  411. STDMETHODIMP CAutoJPEG::XDualJPEG::get_ClassID(BSTR FAR* retval)
  412. {
  413.     if (retval == NULL)
  414.         return E_POINTER;
  415.  
  416.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  417.  
  418.     TRY_DUAL(IID_ITurboCADFilter)
  419.     {
  420.         *retval = pThis->GetClassID();
  421.         return S_OK;
  422.     }
  423.     CATCH_ALL_DUAL
  424. }
  425.  
  426. STDMETHODIMP CAutoJPEG::XDualJPEG::get_Description(BSTR FAR* retval)
  427. {
  428.     if (retval == NULL)
  429.         return E_POINTER;
  430.  
  431.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  432.  
  433.     TRY_DUAL(IID_ITurboCADFilter)
  434.     {
  435.         *retval = pThis->GetDescription();
  436.         return S_OK;
  437.     }
  438.     CATCH_ALL_DUAL
  439. }
  440.  
  441. STDMETHODIMP CAutoJPEG::XDualJPEG::get_Info(BSTR FAR* retval)
  442. {
  443.     if (retval == NULL)
  444.         return E_POINTER;
  445.  
  446.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  447.  
  448.     TRY_DUAL(IID_ITurboCADFilter)
  449.     {
  450.         *retval = pThis->GetInfo();
  451.         return S_OK;
  452.     }
  453.     CATCH_ALL_DUAL
  454. }
  455.  
  456. STDMETHODIMP CAutoJPEG::XDualJPEG::get_LastError(BSTR* retval)
  457. {
  458.     if (retval == NULL)
  459.         return E_POINTER;
  460.  
  461.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  462.  
  463.     TRY_DUAL(IID_ITurboCADFilter)
  464.     {
  465.         *retval = pThis->GetLastError();
  466.         return S_OK;
  467.     }
  468.     CATCH_ALL_DUAL
  469. }
  470.  
  471. STDMETHODIMP CAutoJPEG::XDualJPEG::CheckFlat(IDispatch* ThisFilter, BSTR FileName, long ContextFlags, VARIANT FAR* QueryString, long FAR* retval)
  472. {
  473.     if (retval == NULL)
  474.         return E_POINTER;
  475.  
  476.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  477.  
  478.     TRY_DUAL(IID_ITurboCADFilter)
  479.     {
  480.         CString strFileName(FileName);
  481.         *retval = pThis->CheckFlat(ThisFilter, strFileName, ContextFlags, QueryString);
  482.         return S_OK;
  483.     }
  484.     CATCH_ALL_DUAL
  485. }
  486.  
  487. STDMETHODIMP CAutoJPEG::XDualJPEG::PreviewFlat(IDispatch* ThisFilter, BSTR FileName, long ThumbWidth, long ThumbHeight, BSTR FAR* Description, VARIANT FAR* Thumbnail, long FAR* retval)
  488. {
  489.     if (retval == NULL)
  490.         return E_POINTER;
  491.  
  492.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  493.  
  494.     TRY_DUAL(IID_ITurboCADFilter)
  495.     {
  496.         CString strFileName(FileName);
  497.         *retval = pThis->PreviewFlat(ThisFilter, strFileName, ThumbWidth, ThumbHeight, Description, Thumbnail);
  498.         return S_OK;
  499.     }
  500.     CATCH_ALL_DUAL
  501. }
  502.  
  503.  
  504. STDMETHODIMP CAutoJPEG::XDualJPEG::ReadFlat(BSTR FileName, long ContextFlags, IDispatch * Graphics, VARIANT FAR* QueryString, long FAR* retval)
  505. {
  506.     if (retval == NULL)
  507.         return E_POINTER;
  508.  
  509.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  510.  
  511.     TRY_DUAL(IID_ITurboCADFilter)
  512.     {
  513.         CString strFileName(FileName);
  514.         *retval = pThis->ReadFlat(strFileName, ContextFlags, Graphics, QueryString);
  515.         return S_OK;
  516.     }
  517.     CATCH_ALL_DUAL
  518. }
  519.  
  520.  
  521. STDMETHODIMP CAutoJPEG::XDualJPEG::WriteFlat(BSTR FileName, long ContextFlags, IDispatch * Graphics, VARIANT FAR* QueryString, long FAR* retval)
  522. {
  523.     if (retval == NULL)
  524.         return E_POINTER;
  525.  
  526.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  527.  
  528.     TRY_DUAL(IID_ITurboCADFilter)
  529.     {
  530.         CString strFileName(FileName);
  531.         *retval = pThis->WriteFlat(strFileName, ContextFlags, Graphics, QueryString);
  532.         return S_OK;
  533.     }
  534.     CATCH_ALL_DUAL
  535. }
  536.  
  537.  
  538. STDMETHODIMP CAutoJPEG::XDualJPEG::ReadSetup(IDispatch* ThisFilter, VARIANT_BOOL FAR* retval)
  539. {
  540.     if (retval == NULL)
  541.         return E_POINTER;
  542.  
  543.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  544.  
  545.     TRY_DUAL(IID_ITurboCADFilter)
  546.     {
  547.         *retval = pThis->ReadSetup(ThisFilter);
  548.         return S_OK;
  549.     }
  550.     CATCH_ALL_DUAL
  551. }
  552.  
  553.  
  554. STDMETHODIMP CAutoJPEG::XDualJPEG::WriteSetup(IDispatch* ThisFilter, VARIANT_BOOL FAR* retval)
  555. {
  556.     if (retval == NULL)
  557.         return E_POINTER;
  558.  
  559.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  560.  
  561.     TRY_DUAL(IID_ITurboCADFilter)
  562.     {
  563.         *retval = pThis->WriteSetup(ThisFilter);
  564.         return S_OK;
  565.     }
  566.     CATCH_ALL_DUAL
  567. }
  568.  
  569. STDMETHODIMP CAutoJPEG::XDualJPEG::Initialize(IDispatch* ThisFilter, VARIANT_BOOL FAR* retval)
  570. {
  571.     if (retval == NULL)
  572.         return E_POINTER;
  573.  
  574.     METHOD_PROLOGUE(CAutoJPEG, DualJPEG)
  575.  
  576.     TRY_DUAL(IID_ITurboCADFilter)
  577.     {
  578.         *retval = pThis->Initialize(ThisFilter);
  579.         return S_OK;
  580.     }
  581.     CATCH_ALL_DUAL
  582. }
  583.  
  584. // Implement ISupportErrorInfo to indicate we support the 
  585. // OLE Automation error handler.
  586. IMPLEMENT_DUAL_ERRORINFO(CAutoJPEG, IID_ITurboCADFilter)
  587.  
  588. // DUAL_SUPPORT_END
  589.  
  590.  
  591.  
  592.